import Vue from 'vue';
import App from './App';
import router from './router'; //路由文件
import ElementUI from 'element-ui'; //element-ui
import 'element-ui/lib/theme-chalk/index.css'; //element -css
import './assets/style/reset.css'; //标签清除css
import Antd from 'ant-design-vue';  //ant-desing
import 'ant-design-vue/dist/antd.css'; //ant-design  csss
import './assets/style/main.css'; //公共css
import './assets/style/icon/iconfont.css'; //外部图表css

import store from './store/store'; //状态管理
import axios from './assets/script/axios.js'; //请求封装
import utils from './assets/script/utils.js';  //公共js文件
import filters from './server/filters' //全局过滤文件
import selectTag from './components/index.js' //全局组件
import api from './server/api'  //接口文件

import echarts from 'echarts'
// 将echarts注册到Vue组件的原型对象中去
Vue.prototype.$echarts = echarts

Vue.use(selectTag)
Vue.use(Antd);
Vue.use(ElementUI);


import { Message } from 'element-ui'
// Vue.use(Message)
Vue.prototype.$message = Message

Vue.prototype.$utils = utils
Vue.prototype.$axios = axios;
Vue.prototype.$filters = filters;
Vue.prototype.$api = api;

Vue.config.productionTip = false;

// 全局注册过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key,filters[key])
})

router.beforeEach((to, from, next) => {
  console.log(process.env.NODE_ENV) 
  if (to.path === '/') {
    next({ path: '/login' })
  } else {
    next()
  }
});

new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
});
